package ooday04;


public class Test {
    public static void main(String[] args) {
        /*Master master=new Master();
        Dog dog=new Dog("常威",1,"白");
        Chick chick=new Chick("只因",2,"黄");
        Fish fish=new Fish("花花",1,"金");
        master.feed(dog);
        master.feed(chick);
        master.feed(fish);*/




        Animal[]animals=new Animal[6];
        animals[0]=new Dog("常威",1,"黄");
        animals[1]=new Dog("来福",2,"黑");
        animals[2]=new Chick("坤坤",2,"黑");
        animals[3]=new Chick("只因",1,"白");
        animals[4]=new Fish("大眼",1,"金");
        animals[5]=new Fish("黑嘴",1,"红");
        for (int i = 0; i < animals.length; i++) {
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();
            if (animals[i] instanceof Dog){
                Dog dog=(Dog) animals[i];
                dog.lookHome();
                dog.swim();
            }
            if (animals[i]instanceof Chick){
                Chick chick=(Chick) animals[i];
                chick.eggs();
            }
            if (animals[i]instanceof Swim){
                Swim s=(Swim) animals[i];
                s.swim();
            }
        }




        /*Dog dog=new Dog("小黑",4,"黑");
        System.out.println(dog.name);
        dog=null;
        System.out.println(dog.name);

        Dog[] dogs=new Dog[3];
        dogs[0] =new Dog("常威",1,"黄");
        dogs[1] =new Dog("来福",2,"黑");
        dogs[2] =new Dog("打更的",3,"灰");
        System.out.println(dogs[2].name+"说：“我一进门就看见"+dogs[0].name+"在那打"+dogs[1].name+"”");
        for (int i = 0; i < dogs.length; i++) {
            System.out.println(dogs[i].name);
            dogs[i].eat();
        }
        Chick[]chicks=new Chick[2];
        chicks[0]=new Chick("坤坤",2,"黑");
        chicks[1]=new Chick("只因",1,"白");
        System.out.println("练习两年半的"+chicks[0].name+"会打篮球，唱"+chicks[1].name+"你实在是太美");
        for (int i = 0; i < chicks.length; i++) {
            chicks[i].eggs();
        }
        Fish[]fish=new Fish[3];
        fish[0]=new Fish("大眼",1,"金");
        fish[1]=new Fish("黑嘴",1,"红");
        fish[2]=new Fish("斑点",1,"黑白");
        for (int i = 0; i < fish.length; i++) {
            fish[i].eat();
        }*/






        /*Chick chick=new Chick("只因",2,"黄");
        chick.eat();
        chick.drink();
        chick.eggs();
        Dog dog=new Dog("常威",1,"白");
        dog.eat();
        dog.drink();
        dog.lookHome();
        dog.swim();
        Fish fish=new Fish("花花",1,"金");
        fish.eat();
        fish.drink();
        fish.swim();
         */
    }
}